package com.clstu.exception_.homework;

public class HomeWork01 {
    public static void main(String[] args) {
          try {
              if(args.length!=2){
                  throw new ArrayIndexOutOfBoundsException("参数个数不对");//优先抛出的异常优先捕获，后面的异常就没有机会抛出
              }
              int n1=Integer.parseInt(args[0]);
              int n2=Integer.parseInt(args[1]);
              System.out.println(method(n1,n2));
          }catch (NumberFormatException e){
              System.out.println("格式不对");
              System.out.println(e.getMessage());
          }catch (ArrayIndexOutOfBoundsException e){
              System.out.println(e.getMessage());
          }catch (ArithmeticException e){
              System.out.println(e.getMessage());
              System.out.println("数学问题");
          }
    }
    public static int method(int a,int b){
        return a/b;
    }
}
